<template>
  <div class="bg">
    <div class="logo">
      <img src="@/assets/images/logo-w.svg" alt="logo">
    </div>
    <div class="login_box">
      <h1 style="margin-top: 226px;">iConnect@CES-客户体验服务</h1>
      <div id="test" class="form_box">
        <el-form :model="loginForm" label-position="left">
          <el-form-item label>
            <el-input v-model="loginForm.userId" placeholder="请输入用户名">
              <i slot="prefix" class="iconfont icon-yonghuming"></i>
            </el-input>
          </el-form-item>
          <el-form-item v-if="visible" label>
            <el-input type="text" v-model="loginForm.pwd" placeholder="请输入新密码">
              <i slot="prefix" class="iconfont icon-mima"></i>
              <i
                slot="suffix"
                title="显示密码"
                @click="changePass('show')"
                style="cursor:pointer;"
                class="el-input__icon iconfont icon-eye_close"
              ></i>
            </el-input>
          </el-form-item>
          <el-form-item v-else label>
            <el-input type="password" v-model="loginForm.pwd" placeholder="请输入新密码">
              <i slot="prefix" class="iconfont icon-mima"></i>
              <i
                slot="suffix"
                title="隐藏密码"
                @click="changePass('hide')"
                style="cursor:pointer;"
                class="el-input__icon iconfont icon-avatar-man"
              ></i>
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              class="submit-btn"
              type="primary"
              :loading="loading"
              style="width:100%"
              @click="login"
            >登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  components: {},
  data () {
    return {
      name: "登录",
      loginForm: {
        userId: "36467",
        pwd: "123456",
        deviceCode: "misakamikotoichi1"
      },
      visible: true,
      loading: false
    };
  },
  methods: {
    login () {
      this.loading = true;
      this.$store
        .dispatch("Login", this.loginForm)
        .then(() => {
          this.loading = false;
          this.$router.push({ path: this.redirect || "/" });
        })
        .catch(() => {
          this.loading = false;
        });
    },
    changePass (value) {
      this.visible = !(value === "show");
    }
  }
};
</script>
<style lang="scss" scoped>
.bg {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: url("~@/assets/images/login_bg_new.jpg") no-repeat center;
  background-size: cover;
  min-height: 600px;
  .logo {
    margin-top: 50px;
    padding-left: 3.66%;
    img {
      height: 36px;
    }
  }
  .login_box {
    color: #999;
    position: absolute;
    top: 0px;
    right: 0px;
    padding-left: 30px;
    padding-right: 30px;
    background-color: rgba(255, 255, 255, 0.7);
    height: 100%;
    h1 {
      font-size: 28px;
      color: #169bd5;
      text-align: center;
    }
    .form_box {
      width: 330px;
      margin: 0 auto;
      padding: 40px 20px 0px;
      /deep/ .el-input .el-input__inner {
        padding-left: 30px !important;
        padding-right: 15px !important;
      }
    }
  }
}
</style>
